<!DOCTYPE html>
<html>

<head>
  <title> <%= title %> </title>
  <%- include common %>
</head>

<body>
  <%- include('head',{title:'home'}) %>
  <div class="container">

    <h3><%= title %></h3>
    <p>Welcome to <%= title %></p>

    <% if(username){ %>
      <p>欢迎: <%- username %> </p>
      <p>当前时间: <span id="currentTime">  </span></p>
      <button class="btn btn-danger" onclick="location.href='/users/logout'">注销登录</button>
    <% } else{ %>
        <button class="btn btn-primary" onclick="location.href='/login' ">立即登录</button>
        <button class="btn btn-success" onclick="location.href='/register' ">马上注册</button>
    <% } %>
  </div>
  
</body>
<script>
  window.onload = function(){
    initTIme();

    setInterval(initTIme,1000);
  }

  function initTIme(){
      var time = new Date();
      var year = time.getFullYear();
      var month = time.getMonth() +1 ;
      var day = time.getDate() 
      var hour = time.getHours();
      var min = time.getMinutes()
      var sec = time.getSeconds();
      $("#currentTime").text(`${year}-${month}-${day} ${hour}:${min}:${sec}`)
  }
</script>
</html>